import 'package:dio/dio.dart';

import '../dio_service.dart';


/// 产品相关API端点
class ProductEndpoints {
  static const String AD_LIST = '/product/advertising/list';
  static const String LIST = '/product/list';
  static const String DETAIL = '/product/detail';
}

/// 产品API服务
class ProductApiService {
  /// 获取产品广告列表
  static Future<Response> getAdList() async {
    return await DioService().get(ProductEndpoints.AD_LIST);
  }

  /// 获取产品列表
  static Future<Response> getList({
    num? page,
    num? size,
    Map<String, dynamic>? filters,
  }) async {
    final queryParameters = <String, dynamic>{};

    if (page != null) queryParameters['page'] = page;
    if (size != null) queryParameters['size'] = size;
    if (filters != null) queryParameters.addAll(filters);

    return await DioService().post(
      ProductEndpoints.LIST,
      data: queryParameters,
    );
  }

  /// 获取产品详情
  static Future<Response> getDetail(String productId) async {
    return await DioService().get(
      ProductEndpoints.DETAIL,
      queryParameters: {'id': productId},
    );
  }
}
